package com.company.sendemo.basics.akJavaString.basicsstring;

//        Java遍历一个字符串的每一个字母

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import jxl.write.DateTime;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

//char 转 String      Sting 转 char
public class Five_Traverse {
    public static void main(String[] args) {
        String json = "123%0002^123&#$we*ferfer";


        //indexof  获得指定字符在字符串里第一次出现的下标
        System.out.println(json.indexOf("2"));
        //lastIndexOf  获得指定字符在字符串里第一次出现的下标  返向查询
        System.out.println(json.lastIndexOf("123"));
//1
        for (int i = 0; i < json.length(); i++) {
            char c = json.charAt(i);
            System.out.print(c); //123%0002^123&#$we*ferfer
        }
        System.out.println();
//2
        char[] c = json.toCharArray();
        for (char cc : c) {
            System.out.print(cc);
        }
        System.out.println();
//3
        for (int i = 0; i < json.length(); i++) {
            String subStr = json.substring(i, i + 1);
            System.out.print(subStr);
            if (subStr == "^") {

            }
        }
        int j = 2;
        System.out.println("POSNR" + j);

        HashMap hashMap = new HashMap();
        int version = 0;
        int ver = 2;
        if (ver > version) {
            version = ver;
        }
        hashMap.put("version",version+1);
        System.out.println(hashMap+"hashMap");

        HashMap map = new HashMap();
         String database = null;
        System.out.println((database == null || database.equals(""))?false:true);
        map.put("ffff", Integer.valueOf("123"));
        if (false){
//            map.put("NUMV", Integer.valueOf(""));
                    map.put("ffff",new BigDecimal(""))
            ;
        }


        JSONObject jsonObject = new JSONObject(map);
        System.out.println(jsonObject+"***************");
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String str = sf.format(new Date());
        System.out.println(str);
        SimpleDateFormat DATE = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat TIME = new SimpleDateFormat("HH:mm:ss");
        Date dat =  new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);


        SimpleDateFormat sdfh = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
        Date dateh = new Date();
        String formattedDate = sdfh.format(dateh);
        System.out.println(dateh);



        String hh = dat.toString();
        System.out.println(dat.toString());
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//注意月份是MM
//            Date date = sdfh.parse(String.valueOf(new Date()));
//            System.out.println(date+"*********");
            DateFormat fmt =new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sdfhh = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
            String dateString = "Mon Jul 03 18:27:46 CST 2023";
            Date date = new Date();
            System.out.println("******************");
//            System.out.println(date+"&&&&&&&&&&&");
//            System.out.println(sdfhh.parse(String.valueOf(date))+"&&&&&&&&&&&");
//            System.out.println(sdfhh.parse(dateString)+"&&&&&&&&&&&");
//            System.out.println(fmt.format(dateString)+"&&&&&&&&&&&");
//            System.out.println();




            SimpleDateFormat sfs = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.CHINA);
            Date dates = null;
            dates = sfs.parse(dateString);
            SimpleDateFormat sf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
            System.out.println(sf1.format(dates));
        }catch (Exception e){
            e.printStackTrace();
        }



        Map maps = new HashMap<String, Object>();
        maps.put("1", "fds");
        maps.put("2", "valu");
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        list.add(maps);
        list.add(maps);
//        System.out.println(list);
        for (Map<String, Object> m : list)
        {

//            System.out.println(m.get(1)+"888888888");
//            System.out.println(m);
            JSONObject jsonObject1 = new JSONObject(m);
            String o = jsonObject1.get("2").toString();
//            System.out.println(o);

//            for (String k : m.keySet())
//            {
//                System.out.println(k + " : " + m.get(k));
//            }
        }

//        JSONObject jsonObjects = (JSONObject) JSONObject.parse("");
//        System.out.println(jsonObjects);
//            JSONArray jsonArray = jsonObjects.getJSONArray("IT_AFPO");
//            JSONArray jsonArrays = jsonObjects.getJSONArray("IT_RESB");
//        System.out.println(jsonArray);
//        System.out.println(jsonArrays);


}



}



